# -*-coding:Utf-8 -*
""" Weapon
"""
import bge,mathutils,math,aud,random
from time import time
if __name__ == "__main__" or not "core" in bge.__dict__:
	raise ImportError("this module is not standalone, please import sealed zone module.")
Core = bge.core
Inputs = Core.inputs
Gameplay = Core.gameplay
SZ_Globals = Core.SZ_Globals
device = SZ_Globals['AU_Device']

class FireWeapon(Gameplay.Weapon):
	
	def OneShot(self,weapon,active,*args,**kwargs):
		if not active:
			return
		"""print("azglu")
		if self.inClip == 0:
			weapon.reloadingFunc(active)
			return """
			
		cam = weapon.weaponGameOb.scene.active_camera
		direction = cam.getScreenVect(0.5,0.5)
		direction.negate()
		direction = direction+cam.worldPosition
		fire_result = weapon.playerOb.rayCast(direction,cam,cam.far,'',1)
		if fire_result[1] != None:
			weapon.weaponGameOb.scene.objects["grubitest"].worldPosition = fire_result[1]
			#weapon.weaponGameOb.scene.objects["grubitest"].setParent(fire_result[0])
		#print(fire_result)
		
	def Ironsight(self,weOb,active,*args,**kwargs):
		return
		
	def ReloadWeapon(self,weOb,active,*args,cartridgeClip=1,**kwargs):
		if not active:
			return
		if self.ammo >=  cartridgeClip:
			self.inClip = cartridgeClip
		else:
			self.inClip = self.ammo
		return
		
	def OnSelect(self,weOb,newItem,*args,**kwargs):
		return
	def OnTake(self,weOb,*args,**kwargs):
		return
	def PickUpFireWeapon(self,weOb,active,*args,maxAmmo=36,defaultAmmo=6,**kwargs):
		return
